﻿//-----------------------------------------------------------------
//
// @(#)$Id: ReturnsOrderDetail.aspx.cs,v 1.0 2013/12/13 17:40:05 lichunhua Exp $
// @(#)$Author: lichunhua  $
// @(#)$Date: 2013/12/13 17:40:05 $
// @(#)$Description:
//
//
//
//                 All Rights Reserved.
//-----------------------------------------------------------------
using System;
using System.Data;
using System.Web.UI.WebControls;
using ebay.Dal.CenterDB_EbayTableAdapters;
using ebay.Dal.CenterDB_LTableAdapters;

public partial class UI_Bas_ReturnsOrderDetail : System.Web.UI.Page
{
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        ddlProcessingStatus.Items.Insert(0, new ListItem("《--请选择--》", ""));
        ddlProcessingStatus.Items.Insert(1, new ListItem("重发", "重发"));
        ddlProcessingStatus.Items.Insert(2, new ListItem("退款", "退款"));

        //ebay帐号
        T_EbayAccountTableAdapter adapter = new T_EbayAccountTableAdapter();
        ddlebayUserId.DataSource = adapter.GetData();
        ddlebayUserId.DataTextField = "EbayUserId";
        ddlebayUserId.DataBind();
        ddlebayUserId.Items.Insert(0, new ListItem("《--请选择--》", " "));
    }

    string act="";
    protected void Page_Load(object sender, EventArgs e)
    {
        act = Request.QueryString["act"];
        if (!IsPostBack)
        {
            switch (act)
            {
                case "I":
                    break;
                case "e":
                    {
                        string returnsid = Request.QueryString["id"];
                        T_ReturnsOrderTableAdapter adapter = new T_ReturnsOrderTableAdapter();
                        DataTable dt = adapter.GetDataById(returnsid);
                        DataRow r = dt.Rows[0];
                        this.txtReturnsOrderId.Value = r["ReturnsOrderId"].ToString();
                        this.txtOrderId.Value = r["OrderId"].ToString();
                        this.txtRemarks.Value = r["Remarks"].ToString();
                        txtReturnsOrderId.Attributes["readonly"] = "readonly";
                    }
                    break;
            }
        }
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (Session["UserId"] == null)
        {
            WebUtility.ShowMsg("登陆超时,请重新登陆", this);
            return;
        }
        string userId = Session["UserId"].ToString();
         switch (act)
            {
                case "e":
                    {
                        string returnsid = Request.QueryString["id"];
                        ebay.Dal.ReturnsOrder returns = new ebay.Dal.ReturnsOrder();
                        int val = returns.Match(returnsid, ddlebayUserId.SelectedValue, txtOrderId.Value,0, userId, ddlProcessingStatus.SelectedIndex,txtRemarks.Value);
                        if (val > 0)
                        {
                            Response.Write("<script>alert('退货单处理成功!');window.location.href='ReturnsOrder.aspx';</script>");
                        }
                        else
                        {
                            Response.Write("<script>alert('请输入正确的订单号和ebay帐号!...');</script>");
                        }
                    }
                    break;
            }        
    }
}
